package com.xbts.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xbts.common.annotation.Log;
import com.xbts.common.core.controller.BaseController;
import com.xbts.common.core.domain.AjaxResult;
import com.xbts.common.enums.BusinessType;
import com.xbts.system.domain.SysUserAuthentication;
import com.xbts.system.service.ISysUserAuthenticationService;
import com.xbts.common.utils.poi.ExcelUtil;
import com.xbts.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * 用户认证Controller
 * @author xbts
 * @date 2023-10-20
 */
@Api("用户认证")
@RestController
@RequestMapping("/system/authentication")
public class SysUserAuthenticationController extends BaseController {

    @Autowired
    private ISysUserAuthenticationService sysUserAuthenticationService;

    /**
     * 查询用户认证列表
     */
    @ApiOperation("查询用户认证列表")
    @PreAuthorize("@ss.hasPermi('system:authentication:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody SysUserAuthentication sysUserAuthentication) {
        startPage(sysUserAuthentication);
        List<SysUserAuthentication> list = sysUserAuthenticationService.selectSysUserAuthenticationList(sysUserAuthentication);
        return getDataTable(list);
    }


    /**
     * 获取用户认证详细信息
     */
    @ApiOperation("获取用户认证详细信息")
    @ApiImplicitParam(name = "id", value = "用户认证ID", required = true, dataType = "String", paramType = "path", dataTypeClass=String.class)
    @PreAuthorize("@ss.hasPermi('system:authentication:list')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(sysUserAuthenticationService.selectSysUserAuthenticationById(id));
    }

    /**
     * 新增用户认证
     */
    @ApiOperation("新增用户认证")
    @PreAuthorize("@ss.hasPermi('system:authentication:add')")
    @Log(title = "用户认证", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SysUserAuthentication sysUserAuthentication) {
        return toAjax(sysUserAuthenticationService.insertSysUserAuthentication(sysUserAuthentication));
    }

    /**
     * 修改用户认证
     */
    @ApiOperation("修改用户认证")
    @PreAuthorize("@ss.hasPermi('system:authentication:edit')")
    @Log(title = "用户认证", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserAuthentication sysUserAuthentication) {
        return toAjax(sysUserAuthenticationService.updateSysUserAuthentication(sysUserAuthentication));
    }

    /**
     * 删除用户认证
     */
    @ApiOperation("删除用户认证")
    @ApiImplicitParam(name = "ids", value = "用户认证ID集合", required = true, dataType = "String", paramType = "path", dataTypeClass=String.class)
    @PreAuthorize("@ss.hasPermi('system:authentication:remove')")
    @Log(title = "用户认证", businessType = BusinessType.DELETE)
	@PostMapping("/batchDelete")
    public AjaxResult batchDelete(@RequestBody List<String> ids) {
        return toAjax(sysUserAuthenticationService.deleteSysUserAuthenticationByIds(ids));
    }
}
